﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    [Serializable]
    public class Horary
    {
        public Collection<HoraryDay> listHoraryDays { get; set; }
        public long code { get; set; }
        public long codSubjectToTeacher { get; set; }
        public string gestion { get; set; }
        public char activity { get; set; }

        public Horary()
        {
            listHoraryDays = new Collection<HoraryDay>();
            //foreach (Days day in Enum.GetValues(typeof(Days)))
            //    foreach (Hours hour in Enum.GetValues(typeof(Hours)))
            //        listHoraryDays.Add(new HoraryDay(day, hour));                    
        }

        public Days getDayFromInt(int dayInt)
        {
            foreach (Days day in Enum.GetValues(typeof(Days)))
                if ((int)day == dayInt)
                    return (day);
            return (Days.Monday);
        }

        public Hours getHoursFromInt(int hourInt)
        {
            foreach (Hours hour in Enum.GetValues(typeof(Hours)))
                if ((int)hour == hourInt)
                    return (hour);
            return (Hours.Seven);
        }

        public void Remove(Days day, Hours hour)
        {
            for (int i = 0; i < listHoraryDays.Count; i++)
            {
                //for (int j = i; j < listHoraryDays.Count; j++)
                {
                    if ((int)day == listHoraryDays[i].getDays() && (int)hour == listHoraryDays[i].getHours())
                    {
                        listHoraryDays.RemoveAt(i);
                    }
                }
            }
        }

        public string getCodCourse(Days day, Hours hour)
        {
            for (int i = 0; i < listHoraryDays.Count; i++)
            {
                if ((int)day == listHoraryDays[i].getDays() && (int)hour == listHoraryDays[i].getHours())
                {
                    return listHoraryDays[i].getCodCourse();
                }
            }
            return ("");
        }
        private Collection<int> getAllHoursOfDay(Days day)
        {
            Collection<int> result = new Collection<int>();
            for (int i = 0; i < listHoraryDays.Count; i++)
            {
                if ((int)day == listHoraryDays[i].getDays())
                {
                    result.Add(listHoraryDays[i].getHours());
                }
            }
            return (result);
        }
    }
}
